<template>
	<view class="uni_box home">
		<navbar title='修改手机号' :yin="false">
		</navbar>
		<image class="img_bj" :src="ossThree(info.customlogin.bg_image)"/>
		<!-- <image class="img_bj" src="/static/img/img_bj.png"/> -->
		<view class="loginview">
			<view class="content">
                <!-- <view class="uone">
					<view class="ushuru">
						<u-input style="flex: 1;" v-model="oldmobile" type="text" :border="false" placeholder="请输入手机号" disabled/>
					</view>
				</view> -->
				<view class="uone">
					<view class="ushuru">
						<u-input style="flex: 1;" v-model="mobile" type="text" :border="false" placeholder="请输入新手机号"/>
					</view>
				</view>
				<view class="uone">
					<view class="ushuru">
						<u-input style="flex: 1;" v-model="code" type="text" :border="false" placeholder="请输入验证码"/>
						<view class="huoqu"  v-if="isTimer">{{time}}s</view>
						<view class="huoqu" v-else @click="lockSheet">获取验证码</view>
					</view>

				</view>

				<view class="sbotview">
					<view class="tologin btn" @click="getregisterone">确定</view>
				</view>
			</view>
		</view>
		

		<u-select v-model="bshow" :list="blist" @confirm="bconfirm"></u-select>
		<!-- 验证码 -->
		<!-- <YanPop :yanshow="yanshow" :email="email" :isTimer="isTimer" :time="time"  @yanclose="yanclose" @yanbtn="yanbtn" @getcode="lockSheet"></YanPop> -->
	</view>
</template>

<script>
//  import YanPop from "@/components/YanPop/YanPop";
	export default {
		components:{
			// YanPop
		},
		data() {
			return {
				value:'',
				wang:'',
				bshow:false,
				blist:[
					{
						value: '1',
						label: '江'
					},
					{
						value: '2',
						label: '湖'
					}
				],
				yanshow:false,

				nickname:'',
				
				confirm_password:'',
				phone:'',
				code:'',
				invitation_code:'',

				timer: null,
				time: 60,
				isTimer: false,
				yan:{
					length:false,
					minname:false,//小写字母
					maxname:false,//大写字母
					nums:false,//1个数字
				},
				code:'',
				isgou:false,

				mobile:'',
				captcha:'',
				password:'',
				invite_code:'',
				info:{
					customlogin:{
						bg_image:''
					}
				},
				

                oldmobile:''


			}
		},
		onLoad(option) {
            this.getinfo()
		},
		onShow() {
		},
		methods: {
            async getinfo(){
				let res = await this.$u.api.user();
				// console.log(res)
				this.user = res.data
                this.oldmobile =  this.hideMiddleDigits(res.data.mobile)
			},
			async getconfig(){
				let res = await this.$u.api.config({
				});
				this.info = res
				// console.log(res)
			},
			xuanwang(){
				this.bshow = true
			},
			bconfirm(e){
				console.log(e)
				this.wang = e[0].value
			},
			getrightClick(){
				this.navrouter("/pages/TPage/BiRecord?type=2");
			},
			getfan(){
				uni.navigateBack()
			},
			tologin(){
				uni.reLaunch({ url: '/pages/login/login' })
			},
			yanclose(){
				this.yanshow = false
				this.verify_code = ''
			},
			yanbtn(e){
				console.log(e)
				this.verify_code = e
				this.getregister()
			},
			async lockSheet() {
				if(!this.mobile){
					this.$u.toast("请输入手机号");
					return false;
				}
				
				let res = await this.$u.api.send({
					mobile: this.mobile,
					event:'changemobile'
				});
				this.isTimer = true;
				this.timer = setInterval(() => {
					this.time--
					if (this.time < 0) {
						this.isTimer = false;
						this.time = 60;
						clearInterval(this.timer);
					};
				}, 1000);
				this.$u.toast("发送成功");
				// this.yanshow = true
				// this.initYpRiddler()
				// this.$refs.captcha.initYpRiddler();
				// this.$refs.captcha.verify();
			},
			getregisterone(){
				if(!this.mobile){
					this.$u.toast('请输入手机号');
					return false
				}
				if(!this.code){
					this.$u.toast('请输入验证码');
					return false
				}

				this.getregister()
			},
			async getregister(){
				//注册
				let res = await this.$u.api.changemobile({
					mobile:this.mobile,
					captcha:this.code
				});
				console.log(res)
				this.$u.toast('修改成功');
                
				// uni.reLaunch({ url: '/pages/login/login' })
			},
			inputchange(e){
				console.log(e)
				let nums = e

				if(nums.length>=8&&nums.length<=32){
					this.yan.length = true
				}else{
					this.yan.length = false
				}
				if(this.containsAtLeastOneNumber(e)){
					this.yan.nums = true
				}else{
					this.yan.nums = false
				}
				if(this.containsAtLeastOneLowercaseLetter(e)){
					this.yan.minname = true
				}else{
					this.yan.minname = false
				}
				if(this.containsAtLeastOneLowercaseLettertwo(e)){
					this.yan.maxname = true
				}else{
					this.yan.maxname = false
				}
			},
			containsAtLeastOneNumber(str) {//验证1个数字
				return /\d/.test(str);
			},
			containsAtLeastOneLowercaseLetter(str) {//验证1个小写字母
				return /[a-z]/.test(str);
			},
			containsAtLeastOneLowercaseLettertwo(str) {//验证1个小写字母
				return /[A-Z]/.test(str);
			},
			xieyi(e){
				if(e == 1){
					//用户协议
					this.navrouter("/pages/TPage/xieyi?type=agreement");
				}else if(e == 2){
					//隐私协议
					this.navrouter("/pages/TPage/xieyi?type=privacy");
				}
			},
			changegroup(e){
				// console.log(e)
				// if(e.value){
				// 	this.checked = 2
				// }else{
				// 	this.checked = 0
				// }
				this.isgou = !this.isgou
			},

		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.uni_box{
		position: relative;
		min-height: 100vh;
	}
	.img_bj{
		position: absolute;
		width: 100%;
		height: 100%;
	}
	.loginview{
		position: relative;
		min-height: 100vh;
		background-color: #fff;
	}
	.lone{
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 40rpx;
		// #ifdef MP
		padding-top: calc(var(--status-bar-height) + 40rpx);;
		// #endif
		.lfan{
			width: 40rpx;
			height: 40rpx;
			margin-right: 20rpx;

		}
		.Loginname{
			font-family: Source Han Sans CN;
			font-weight: bold;
			font-size: 40rpx;
			color: #000000;
		}
	}
	.logoview{
		position: relative;
		display: flex;
		flex-direction: column;
		margin-bottom: 59rpx;
		margin-top: 40rpx;
		.loginname{
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 62rpx;
			color: #333333;
		}
		.loginmiao{
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 28rpx;
			color: #666666;
			margin-top: 15rpx;
			display: block;
		}
		.loview{
			position: absolute;
			width: 100%;
			height: 100%;
			border-radius: 40rpx;
			display: block;
			
		}
	}
	.chongji{
		width: 38rpx;
		height: 36rpx;
	}
	.content{
		// background-color: #fff;
		padding: 30rpx 38rpx;
		.mpone{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 80rpx;
			.touview{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				margin-right: 30rpx;
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.tou2{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				position: absolute;
			}
			.xj{
				position: relative;
				z-index: 1;
				width: 42rpx;
				height: 38rpx;
			}
			.mpright{
				flex: 1;
				display: flex;
				flex-direction: column;
				.yxname{
					font-family: Source Han Sans CN;
					font-weight: bold;
					font-size: 24rpx;
					color: #000000;
				}
				.dengview{
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-top: 10rpx;
					.idnum{
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 24rpx;
						color: #000000;
						display: inline-block;
						margin-right: 13rpx;
					}
					.dengji{
						padding: 5rpx 30rpx;
						background: #FF8004;
						border-radius: 14rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 20rpx;
						color: #FFFFFF;
					}
				}
			}
		}
		.qian{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 45rpx;
			.qbiao{
				display: inline-block;
				width: 8rpx;
				height: 36rpx;
				background: #FF8004;
				margin-right: 8rpx;

			}
			.qname{
				font-family: Source Han Sans CN;
				font-weight: bold;
				font-size: 30rpx;
				color: #000000;
			}
		}
		.uone{
			display: flex;
			flex-direction: column;
			margin-bottom: 40rpx;
			.uhead{
				display: flex;
				flex-direction: row;
				align-items: center;

			}
			.usdt{
				width: 46rpx;
				height: 46rpx;
				margin-right: 12rpx;
			}
			.Input-label{
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 30rpx;
				color: #000000;
				display: inline-block;
				margin-left: 20rpx;
			}
		}
		// .uone:last-child{
		// 	margin-bottom: 30rpx;
		// }
		.wangmi{
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 26rpx;
			color: #FF7E00;
		}
		.ushuru{
			padding: 20rpx 30rpx;
			// background: #F7F7F7;
			background: #F5F5F5;
            border-radius: 30rpx;
			border-radius: 20rpx;
			border: 1px solid #FFFFFF;
			display: flex;
			align-items: center;
			flex-direction: row;
			min-height: 80rpx;
			// border: 1rpx solid #FFFFFF;
			/deep/.u-input__input{
				font-weight: 400;
				font-size: 32rpx;
				color: #000000;
			}
			.xuantit{
				color: #c0c4cc;
			}
			.xactive{
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
			}
			.xia{
				margin-left: auto;
				width: 16rpx;
				height: 10rpx;
			}
			.quanbu{
				margin-left: 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #010101;
			}
			.huoqu{
				padding: 8rpx 0rpx;
				margin-left: 10rpx;
				font-weight: 500;
				font-size: 28rpx;
				color: rgba(255, 94, 64, 1);
			}
		}
		.keyong{
			display: block;
			text-align: right;
			font-family: Source Han Sans CN;
			font-weight: 400;
			font-size: 22rpx;
			color: #010101;
			margin-bottom: 75rpx;
		}
		
		.sbotview{
			margin: 100rpx 0 40rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.shoufei{
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 22rpx;
				color: #010101;
				display: block;
				margin-bottom: 15rpx;


			}
			.tologin{
				width: 100%;
				height: 96rpx;
				background: #CCCCCC;
				border-radius: 45rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-weight: 500;
				font-size: 32rpx;
				color: #999999;
			}
			.btn{
				background: linear-gradient(90deg, #FF8F39, #FF4D43);
				color: #fff;
			}
			.Existing-account{
				display: block;
				text-align: center;
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 26rpx;
				color: #A5A5A5;
				margin-top: 40rpx;
			}
			.zhutit{
				color: #4266fd;
			}
		}

		.tiview{
			display: flex;
			flex-direction: row;
			justify-content: center;
			.yueicon{
				margin-right: 14rpx;
				width: 36rpx;
				height: 36rpx;
			}
			.RegistrationTips{
				font-weight: 500;
				font-size: 26rpx;
				color: #999999;
				text-align: center;
			}
			.tibiao{
				color: #093877;
				display: inline-block;
				margin: 0 1rpx;
			}
		}
		// padding-bottom: 150rpx;
	}
	.validate{
		display: flex;
		flex-direction: column;
		.validateitem{
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 10rpx;
			.cha{
				width: 26rpx;
				height: 26rpx;
				margin-right: 10rpx;
			}
			.valname{
				font-family: Source Han Sans CN;
				font-weight: 400;
				font-size: 26rpx;
				color: #000000;
			}

		}
	}
	.xies{
		color: #4266fd;
	}
</style>
